<template>
  <div>
    <el-breadcrumb>
      <el-breadcrumb-item>房型管理</el-breadcrumb-item>
      <el-breadcrumb-item>房型操作日志</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="room-content">
      <el-form :inline="true">
        <el-form-item>
          <el-dropdown @command="setRoomType">
            <span class="el-dropdown-link">
              {{roomTypeStr}}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item :command="{title:'全部房型类型',id:''}">全部房型类型</el-dropdown-item>
              <el-dropdown-item :command="{title:'全日房',id:'1'}">全日房</el-dropdown-item>
              <el-dropdown-item :command="{title:'钟点房',id:'2'}">钟点房</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-form-item>
        <el-form-item>
          <el-dropdown @command="setType">
            <span class="el-dropdown-link">
              {{typeStr}}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item :command="{title:'全部操作类型',id:''}">全部操作类型</el-dropdown-item>
              <el-dropdown-item :command="{title:'房态',id:'0'}">房态</el-dropdown-item>
              <el-dropdown-item :command="{title:'房价',id:'1'}">房价</el-dropdown-item>
              <el-dropdown-item :command="{title:'房量',id:'2'}">房量</el-dropdown-item>
              <el-dropdown-item :command="{title:'房型',id:'3'}">房型</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-form-item>
        <el-form-item>
          <el-input v-model="sendData.saleHotelId"
            placeholder="请输入酒店名称"
            clearable
            @keyup.enter.native="search"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input placeholder="请输入房型"
            v-model="sendData.saleRoomId"
            @keyup.enter.native="search"
            clearable></el-input>
        </el-form-item>
        <el-form-item label="操作时间">
          <el-date-picker v-model="time"
            type="daterange"
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            style="width: 220px;"
            @change="timeSearch">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="操作人">
          <el-input v-model="sendData.operator"
            placeholder="请输入操作人姓名"
            @keyup.enter.native="search"
            clearable></el-input>
        </el-form-item>
        <el-form-item>
          <div class="search-button">
            <el-button type="primary"
              @click="search">
              <i class="el-icon-search"></i>
            </el-button>
          </div>
        </el-form-item>
      </el-form>
      <el-form>
        <el-form-item>
          <el-table :data="tableData"
            style="width: 100%"
            max-height="550">
            <el-table-column prop="saleRoomName"
              width="150px"
              label="售卖房型名称">
            </el-table-column>
            <el-table-column prop="roomType"
              width="100px"
              label="售卖房型类型">
            </el-table-column>
            <el-table-column prop="type"
              label="类型"
              width="100px">
            </el-table-column>
            <el-table-column label="变更内容"
              width="300px">
              <template slot-scope="scope">
                <el-popover trigger="hover"
                  placement="top">
                  <div>
                    {{ scope.row.content}}
                  </div>
                  <div slot="reference"
                    class="name-wrapper">
                    <p>{{ scope.row.content}}</p>
                  </div>
                </el-popover>
              </template>
            </el-table-column>
            <el-table-column prop="dateScope"
              label="涉及时间范围">
            </el-table-column>
            <el-table-column prop="operator"
              label="操作人">
            </el-table-column>
            <el-table-column prop="createTime"
              label="操作时间">
            </el-table-column>
            <el-table-column prop="saleHotelName"
              label="酒店名称">
            </el-table-column>
          </el-table>
        </el-form-item>
        <el-form-item style="margin-top: 20px;">
          <el-pagination @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="sendData.pageNo"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="sendData.pageSize"
            layout="total, prev , pager , next, sizes, jumper"
            :total="sendData.total">
          </el-pagination>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import { getRoomListLog } from "../../public/js/saleRoom";
const Breadcrumb = () => import("@/components/common/Breadcrumb");

export default {
  name: "Message",
  data() {
    return {
      roomTypeStr: "全部房型类型",
      typeStr: "全部操作类型",
      content: {
        firstTitle: "房型",
        secondTitle: "房型日志",
        type: "close"
      },
      centerDialogVisible: false,
      tableData: [],
      time: [],
      sendData: {
        pageNo: 1,
        pageSize: 10,
        roomType: "",
        type: ""
      }
    };
  },
  created() {
    this.getRoomListLog();
  },
  methods: {
    getRoomListLog() {
      this.sendData.start = this.time ? this.time[0] : "";
      this.sendData.end = this.time ? this.time[1] : "";
      getRoomListLog(this.sendData).then(res => {
        this.tableData = res.data.roomLogEntities;
        this.sendData.total = res.data.total;
      });
    },
    _reset() {
      this.sendData.pageNo = 1;
      this.sendData.pageSize = 10;
      this.getRoomListLog();
    },
    setRoomType(val) {
      this.roomTypeStr = val.title;
      this.sendData.roomType = val.id;
    
      this._reset();
    },
    setType(val) {
      this.typeStr = val.title;
      this.sendData.type = val.id;
      this._reset();
    },
    timeSearch(val) {
      this._reset();
    },
    search() {
      this._reset();
    },
    handleSizeChange(val) {
      this.sendData.pageSize = val;
      this.getRoomListLog();
    },
    handleCurrentChange(val) {
      this.sendData.pageNo = val;
      this.getRoomListLog();
    }
  },
  components: {
    Breadcrumb
  }
};
</script>
<style lang="scss" scoped>
.room-log {
  .el-form-item {
    margin-bottom: 20px;
    margin-right: 20px;
  }
  .type-select,
  .hotel-select,
  .room-select,
  .search-button,
  .date-select,
  .operation-select {
    float: left;
    margin-right: 20px;
  }

  .type-select {
    width: 15%;
    .el-select {
      width: 80%;
    }
  }
  .date-select {
    width: 22%;
  }
  .operation-select {
    width: 14%;
    margin-right: 0;
  }
  .search-button {
    width: 5%;
  }
  .search-button {
    button {
      padding: 9px 21px;
    }
  }
}
.edit-dialog {
  .edit-content {
    overflow: hidden;
    min-height: 100px;
    .content-left,
    .content-right {
      float: left;
    }
    .content-left {
      width: 32%;
      margin-right: 10px;
    }
    .content-right {
      width: 60%;
    }
    .content-footer {
      margin-top: 35%;
      button {
        font-size: 12px;
        padding: 10px 15px;
      }
    }
  }
}
.room-content {
  background-color: white;
  padding: 20px;
  position: relative;
}
.el-popper[x-placement^="bottom"] {
  width: 100px !important;
  padding: 0;
}
.el-popper[x-placement^="bottom"] .el-form-item .el-form-item__content .title {
  background-color: rgb(241, 243, 248);
  text-align: left;
  padding-left: 20px;
  h1 {
    font-size: 14px;
  }
}
.el-popper[x-placement^="bottom"]
  .el-form-item
  .el-form-item__content
  .radio-style {
  padding: 20px;
  text-align: center;
  overflow: hidden;
  .radio-left,
  .radio-right {
    float: left;
    width: 50%;
  }
}
</style>
